/* 基础主题变量（SaaS 风格） */
:root {
  --bg: #0f172a;          /* slate-900 */
  --panel: #0b1220;       /* deep panel */
  --panel-2: #111827;     /* slate-800 */
  --text: #e5e7eb;        /* slate-200 */
  --muted: #9ca3af;       /* slate-400 */
  --primary: #3b82f6;     /* blue-500 */
  --primary-600: #2563eb; /* blue-600 */
  --border: #1f2937;      /* slate-700 */
  --danger: #ef4444;      /* red-500 */
  --success: #10b981;     /* emerald-500 */
}

[data-theme="light"] {
  --bg: #f8fafc;          /* slate-50 */
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --text: #0f172a;        /* slate-900 */
  --muted: #6b7280;       /* slate-500 */
  --primary: #2563eb;     /* blue-600 */
  --primary-600: #1d4ed8; /* blue-700 */
  --border: #e5e7eb;      /* slate-200 */
}

/* 全局重置与排版 */
* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
}

[data-theme="light"] body { background: var(--bg); }

/* 去除炫彩叠加，保持干净 */

/* 容器与卡片 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  position: relative;
  z-index: 1;
}

/* SaaS 布局框架 */
.shell { display: grid; grid-template-columns: 260px 1fr; height: 100vh; }
.sidebar {
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  padding: 16px 12px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 10px 8px 16px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); color: white; display: grid; place-items: center; font-weight: 800; }
.brand-name { font-weight: 700; }
.nav { display: grid; gap: 16px; }
.nav-group { display: grid; gap: 8px; }
.nav-section { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 8px; }
.nav-link { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav-link:hover { background: rgba(59,130,246,0.10); }
.nav-link.is-active { background: rgba(59,130,246,0.14); border: 1px solid rgba(59,130,246,0.30); }

.workspace { display: grid; grid-template-rows: 64px 1fr; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid var(--border); }
.topbar-title { font-weight: 600; }
.topbar-subtitle { font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.content-area { padding: 18px; overflow: auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  position: relative;
}
/* 去除霓虹外发光 */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.content { padding: 16px; }

/* 表格样式 */
.table-wrapper { overflow: auto; }
.table-wrapper { max-height: calc(100vh - 320px); }
.table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table thead th { position: sticky; top: 0; z-index: 1; }
.table tbody tr:nth-child(odd) { background: rgba(255,255,255,0.02); }
.table thead th {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .02em;
  background: rgba(148,163,184,0.08);
}
.table tbody tr:hover { background: rgba(59,130,246,0.06); }
.table tbody tr td:first-child { border-left: 2px solid transparent; }
.table tbody tr:hover td:first-child { border-left-color: var(--primary); }

/* 表单 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.field { grid-column: span 2; }
.field-3 { grid-column: span 3; }
.field-6 { grid-column: span 6; }

.input, .select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f1729;
  color: var(--text);
  outline: none;
}
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(59,130,246,0.25); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1729;
  color: var(--text);
  cursor: pointer;
  transition: box-shadow .2s ease, border-color .2s ease, transform .04s ease;
}
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn:hover { background: #111b2e; border-color: #24324a; box-shadow: 0 0 0 2px rgba(59,130,246,0.10); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
  border-color: rgba(59,130,246,0.35);
  background: linear-gradient(180deg, rgba(59,130,246,0.25), rgba(59,130,246,0.15));
  color: #eaf2ff;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15) inset;
}
.btn-primary:hover { box-shadow: 0 0 0 2px rgba(59,130,246,0.25) inset, 0 6px 16px rgba(2,132,199,.25); }

.btn-secondary { background: #1b2232; }
.btn-secondary:hover { background: #1f2638; }

.btn-danger { background: #2a1416; border-color: #3b1a1d; color: #ffb4b4; }
.btn-danger:hover { background: #321719; }

/* 工具条与状态 */
.toolbar { display: flex; align-items: center; gap: 10px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* 终端页 */
.terminal-root { height: 100vh; display: flex; flex-direction: column; }
.terminal-toolbar { border-bottom: 1px solid var(--border); }
.terminal-container { flex: 1; padding: 12px; }
.terminal-pane { width: 100%; height: 100%; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.terminal-pane .xterm-viewport::-webkit-scrollbar { width: 10px; }
.terminal-pane .xterm-viewport::-webkit-scrollbar-thumb { background: rgba(59,130,246,0.25); border-radius: 10px; }

/* 文字与徽标 */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 9999px; font-size: 12px; border: 1px solid var(--border); background: #0b111c; color: var(--muted); }
.badge-primary { border-color: rgba(59,130,246,0.35); color: #bfdbfe; background: rgba(59,130,246,0.10); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { width: min(1100px, 92vw); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,0.45); overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 12px; }
.modal-foot { padding: 10px 12px; border-top: 1px solid var(--border); }

/* Toast */
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 10px;
  z-index: 50;
}
.toast {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0e1628;
  color: var(--text);
  box-shadow: 0 10px 20px rgba(0,0,0,0.25);
}
.toast-success { border-color: rgba(16,185,129,0.35); background: rgba(16,185,129,0.12); }
.toast-error { border-color: #4b1a1a; background: #2a1717; }

/* Skeleton */
.skeleton-line {
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(59,130,246,0.08), rgba(59,130,246,0.18), rgba(59,130,246,0.08));
  background-size: 200% 100%;
  animation: ske 1.2s ease-in-out infinite;
}
@keyframes ske {
  0% { background-position: 0% 0%; }
  100% { background-position: -200% 0%; }
}

/* 统一状态组件 */
.state {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
  padding: 28px 12px;
  color: var(--muted);
}
.state-title { font-weight: 600; color: var(--text); }
.state-desc { font-size: 12px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 小屏适配 */
@media (max-width: 900px) {
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .field, .field-3, .field-6 { grid-column: span 2; }
}

